const cloud = require("@cloudbase/node-sdk");

const app = cloud.init({
    env: cloud.SYMBOL_CURRENT_ENV,
});

var db = app.database();
const _ = db.command
const $ = db.command.aggregate
const ZXBbsData = db.collection('ZX-Bbs-Data')
const ZXBbsReply = db.collection('ZX-Bbs-Reply')
const ZXBbsReplyMessage = db.collection('ZX-Bbs-Reply-Message')
const nowDate = new Date().getTime()

// 获取openId云函数入口函数
exports.main = async (event,context,token,gameId) => {
    process.env.TZ = 'Asia/Shanghai'
    const api = event.api
    var params = {}

    if(api=='api-bbs-zuimei-list'){
        const res = await db
        .collection('ZX-Bbs-Reply')
        .aggregate()
        .match({
            cBbsId: "ad4a2ea864472dff0001d660248d5654",
        })
        .addFields({
            imgStrIndex: $.indexOfCP(['$content', 'img'])
        })
        .match({
            imgStrIndex: $.gt(0)
        })
        .limit(200)
        .end()

        return res
    }
};